home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SCLIB.ARJ / SCL1SAMP.EXE / MENUBAR2.C < prev    next >
C/C++ Source or Header  |  1992-01-01  |  4KB  |  205 lines

  1. #include <scl1.h>
  2. #include <scl1keys.h>
  3. #include <scl1clor.h>
  4.  
  5.     /********************************************************************
  6.       MenuSystem2 example. You can display a help-line and gray-out menu
  7.       items with MenuSystem2  */
  8.  
  9. MSBar2 msb[]={
  10.  
  11. /* Menu-bar data:
  12.      Start and end column of each option
  13.      Menu's key SCAN-ASCII code
  14.      String */
  15.  
  16.      1,6,0x2100," File ",
  17.      7,12,0x1200," Edit ",
  18.      };
  19.  
  20. /* first pull-down menu
  21.      row, column position
  22.      string
  23.      hot-key
  24.      1=active,0=inactive option
  25.      help text */
  26.  
  27. MSOptions2 mso0[]={
  28.      2,1," Load ",'L',1,"Load new file",
  29.      3,1," Save ",'S',0,"Save edited file",    /* inactive option */
  30.      4,1," Quit ",'Q',1,"Exit to DOS",
  31.      };
  32.  
  33. /* second pull-down menu */
  34.  
  35. MSOptions2 mso1[]={
  36.      2,7," Mark  ",'M',1,"Mark block",
  37.      3,7," Cut   ",'C',1,"Cut text block",
  38.      4,7," Copy  ",'y',1,"Copy text block",
  39.      5,7," Paste ",'P',1,"Paste text block",
  40.      };
  41.  
  42. /* buffer for storing pull down menu screen area */
  43.  
  44. char WindowBuf[140];
  45.  
  46. /* Pull-down menu box & window information
  47.      top left corner and bottom right corner positions
  48.      number of options
  49.      buffer for saving screen area
  50.      MSOptions structure  */
  51.  
  52. MSWindow2 msw[]={
  53.      1,0,5,7,3,WindowBuf,mso0,
  54.      1,6,6,14,4,WindowBuf,mso1,
  55.      };
  56.  
  57. /* This structure links all previous structures */
  58.  
  59. MSData2 msd=
  60.      {
  61.    /* bar-menu colors */
  62.  
  63.      BLACK_WHITE,WHITE_BLACK+HIGHLIGHT,
  64.  
  65.    /* pull-down menu colors */
  66.  
  67.      WHITE_BLACK,BLACK_WHITE,WHITE_BLACK+HIGHLIGHT,
  68.  
  69.     /* normal and reverse color for inactive options */
  70.  
  71.      BLACK_BLACK+HIGHLIGHT,BLACK_WHITE+HIGHLIGHT,
  72.  
  73.    /* MSBar, MSWindow structures, number of menus and internal variables */
  74.  
  75.      msb,msw,2,0,0,0,
  76.  
  77.      /* text color, line, column, and lenght */
  78.  
  79.      BLACK_WHITE,24,0,80};
  80.  
  81. main()
  82. {
  83. int Mess;
  84.  
  85. InitMouse(IM_SHOW); /* initialize mouse */
  86.  
  87. /* Draw shadows */
  88.  
  89. MenuSystem2(MS_SHADOW_ON,(MSData *)0);
  90.  
  91. /* MenuSystem2 will be ALT sensitive */
  92.  
  93. MenuSystem2(MS_ALT_ON,(MSData *)0);
  94.  
  95. /* draw */
  96.  
  97. MenuSystem2(MS_DRAW,&msd);
  98.  
  99. do
  100.      {
  101.  
  102.      /* a key pressed? */
  103.  
  104.      if(Mess=KeyReady())
  105.           {
  106.  
  107.           /* send key to MenuSystem2 */
  108.  
  109.           Mess=MenuSystem2(MS_KEY,&msd,Mess);
  110.  
  111.           /* If we still have a key it means it was not a MenuSystem2 key,
  112.              discard key. If your program needs to service the keyboard you
  113.              should do it here. */
  114.  
  115.           if(KeyReady())
  116.                GetKey();
  117.           }
  118.      else
  119.  
  120.           /* Let MenuSystem2 check if the mouse has been clicked
  121.              or a selection has been made */
  122.  
  123.           Mess=MenuSystem2(MS_CHECK,&msd);
  124.  
  125.      if(Mess==MS_SELECT)
  126.           {
  127.  
  128.           /* a selection was made, msd.Menu=selected menu */
  129.  
  130.           switch(msd.Menu)
  131.                {
  132.                case 1:
  133.  
  134.                /* first menu, msd.Option=selected option */
  135.  
  136.                     switch(msd.Option)
  137.                          {
  138.                          case 1:
  139.  
  140.                               /* first option */
  141.  
  142.                               MessageOn(BLACK_WHITE,"Load");
  143.                               WaitTime(100);
  144.                               MessageOff();break;
  145.  
  146.                          case 2:
  147.  
  148.                               /* second option, since is inactive
  149.                               we'll never receive this selection */
  150.  
  151.                               MessageOn(BLACK_WHITE,"Save");
  152.                               WaitTime(100);
  153.                               MessageOff();break;
  154.                          case 3:
  155.  
  156.                               /* third option */
  157.  
  158.                               MessageOn(BLACK_WHITE,"Quit");
  159.                               WaitTime(100);
  160.                               MessageOff();
  161.                               break;
  162.                               }
  163.                     break;
  164.  
  165.                case 2:
  166.  
  167.                     /* second menu */
  168.  
  169.                     switch(msd.Option)
  170.                          {
  171.                          case 1:
  172.                               /* first option */
  173.  
  174.                               MessageOn(BLACK_WHITE,"Mark");
  175.                               WaitTime(100);
  176.                               MessageOff();
  177.                               break;
  178.  
  179.                          case 2:
  180.                               /* second option */
  181.  
  182.                               MessageOn(BLACK_WHITE,"Cut");
  183.                               WaitTime(100);
  184.                               MessageOff();
  185.                               break;
  186.                          case 3:
  187.                               /* third option */
  188.  
  189.                               MessageOn(BLACK_WHITE,"Copy");
  190.                               WaitTime(100);
  191.                               MessageOff();
  192.                               break;
  193.                          case 4:
  194.                               /* fourth option */
  195.  
  196.                               MessageOn(BLACK_WHITE,"Paste");
  197.                               WaitTime(100);
  198.                               MessageOff();
  199.                               break;
  200.                          }
  201.                     break;
  202.                }
  203.           }
  204.      }while(msd.Menu != 1 || msd.Option != 3);
  205. }